﻿Imports System.Data.OleDb
Public Class Register
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not User.Identity.Name = "" Then
            MsgBox("you are already a member!!", MsgBoxStyle.Exclamation)
            Response.Redirect("/Default.aspx")
        Else
            RegisterUser.ContinueDestinationPageUrl = Request.QueryString("ReturnUrl")
        End If
    End Sub

    Protected Sub RegisterUser_CreatedUser(ByVal sender As Object, ByVal e As EventArgs) Handles RegisterUser.CreatedUser
        FormsAuthentication.SetAuthCookie(RegisterUser.UserName, False)

        Dim continueUrl As String = RegisterUser.ContinueDestinationPageUrl
        If String.IsNullOrEmpty(continueUrl) Then
            continueUrl = "~/"
        End If

        Dim sql As String = "INSERT INTO userprofile (dinerid,registrationdate) VALUES(@a1,@a2)"
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("mercedesbenzconnectionstring").ConnectionString)
        conn.Open()
        Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)

        cmd.Parameters.AddWithValue("@a1", RegisterUser.UserName)
        cmd.Parameters.AddWithValue("@a2", DateTime.Now.Date)

        cmd.ExecuteNonQuery()
        conn.Close()
        cmd.Dispose()
        conn.Dispose()

        Response.Redirect("~/editprofile.aspx")
    End Sub
End Class